package com.zzz.servlet;

import jakarta.servlet.ServletContext;
import jakarta.servlet.ServletException;
import jakarta.servlet.annotation.WebServlet;
import jakarta.servlet.http.HttpServlet;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.servlet.http.HttpServletResponse;
import jakarta.servlet.http.HttpSession;

import java.io.IOException;

/*
 * @author zzr
 * @date: 2025/07/22  16:53
 * @description:
 */
@WebServlet("/servlet11")
public class Servlet11 extends HttpServlet {
    @Override
    protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {

        // 向请求域中存放数据
        req.setAttribute("request", "requestMessage");

        // 向会话域中存放数据
        HttpSession session = req.getSession();
        session.setAttribute("session", "sessionMesage");

        // 向应用域中存放数据
        ServletContext application = req.getServletContext();
        application.setAttribute("application","applicationMessage");

        req.getRequestDispatcher("servlet22").forward(req,resp);
    }
}
